﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using Model;

namespace BusinnessLogic
{
    public class ManageUsers
    {


        public List<User> PopulateUserlist()
        {
            DataLayer.dlusers DLuserlistfiller = new DataLayer.dlusers();
            DataSet dts = DLuserlistfiller.UserList();

            List<User> userlist = new List<User>();


            for (int i = 0; i < dts.Tables[0].Rows.Count; i++)
            {
                int userid = int.Parse(dts.Tables[0].Rows[i]["UserID"].ToString());
                int roleid = int.Parse(dts.Tables[0].Rows[i]["RoleId"].ToString());
                string login = dts.Tables[0].Rows[i]["Login"].ToString();
                string passwoord = dts.Tables[0].Rows[i]["Passwoord"].ToString();
                string name = dts.Tables[0].Rows[i]["Name"].ToString();
                string voornaam = dts.Tables[0].Rows[i]["FirstName"].ToString();
                string rolnaam = dts.Tables[0].Rows[i]["Role"].ToString();
                int teamid = int.Parse(dts.Tables[0].Rows[i]["TeamId"].ToString());

                User newuser = new User(userid, roleid, login, passwoord, name, voornaam, rolnaam, teamid);
                userlist.Add(newuser);


            }
            return userlist;
        }
        public List<User> PopulateUserlistZonderTeams()
        {
            DataLayer.dlusers DLuserlistfiller = new DataLayer.dlusers();
            DataSet dts = DLuserlistfiller.UserListTeamless();

            List<User> userlist = new List<User>();


            for (int i = 0; i < dts.Tables[0].Rows.Count; i++)
            {
                int userid = int.Parse(dts.Tables[0].Rows[i]["UserID"].ToString());
                int roleid = int.Parse(dts.Tables[0].Rows[i]["RoleId"].ToString());
                string login = dts.Tables[0].Rows[i]["Login"].ToString();
                string passwoord = dts.Tables[0].Rows[i]["Passwoord"].ToString();
                string name = dts.Tables[0].Rows[i]["Name"].ToString();
                string voornaam = dts.Tables[0].Rows[i]["FirstName"].ToString();
                string rolnaam = dts.Tables[0].Rows[i]["Role"].ToString();
                //int teamid = int.Parse(dts.Tables[0].Rows[i]["TeamId"].ToString());

                User newuser = new User(userid, roleid, login, passwoord, name, voornaam, rolnaam);
                userlist.Add(newuser);


            }
            return userlist;
        }
    }
}
